# -*- coding:utf-8 -*-
__author__ = 'zhangbao'
from cart import tools
from commonlib import timetool


def get_total_months(n):
    """
    获取n年月份
    :param n:
    :return:
    """
    # if n == 1:
    #     months = 13
    # elif n == 2:
    #     months = 26
    # else:
    #     months = n*12+3
    n = int(n)
    months = n*12+tools.compute_free_months(n)
    return months


def get_end_date(n):
    """
    获取预付单有效结束日期
    :param n:
    :return:
    """
    months = get_total_months(n)
    #获取n月后日期
    end_date = timetool.get_today_month(n=months)
    #计算n月后日期的前一天日期
    return timetool.get_before_or_after_date(1, 0, end_date)